package objects;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Transcript {
	private Gene parent;
	private String name;
	private String source;
	private String type;
	private ValidPosition bounds;
	private HashMap<Integer, Exon> exons;

	public Transcript(String name, String source, String type, int start,
			int end) {
		this.name = name;
		this.source = source;
		this.type = type;
		this.bounds = new ValidPosition(start, end);
		exons = new HashMap<Integer, Exon>();
		parent = null;
	}

	public String getSource() {
		return source;
	}

	public String getType() {
		return type;
	}

	public void setGeneParent(Gene gene) {
		parent = gene;
	}

	public Gene getGeneParent() {
		return parent;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void addExon(Exon exon) {
		exons.put(exon.getBounds().start, exon);
	}

	public List<Exon> getAllExons() {
		return new ArrayList<Exon>(exons.values());
	}

	public boolean containsExonByStart(int start) {
		return exons.containsKey(start);
	}

	public boolean containsExonByEnd(int end) {
		List<Exon> exonList = new ArrayList<Exon>(exons.values());
		for (Exon ex : exonList) {
			if (ex.getBounds().end == end) {
				return true;
			}
		}
		return false;
	}

	public boolean containsExon(Exon ex) {
		return exons.containsValue(ex);
	}

	public ValidPosition getBounds() {
		return bounds;
	}
}
